<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单</title>
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    <meta http-equiv="X-UA-Compatible" content="chrome=1" />
    <link href="/res/style/simpleui.min.css" rel="stylesheet" type="text/css">
    <link href="/res/style/my/myorder.css?v=20171114" rel="stylesheet" type="text/css">
    <link href="/res/style/base/vectors.2.css" rel="stylesheet" type="text/css">
    <link href="/res/style/sameSale/spotOrderList.css" rel="stylesheet" type="text/css">
</head>
<body>
	<div class="tab" id="tabList">
    </div>
	<div class="order-container" id="parentTemplate">
		<div class="custom" id="order-list"></div>
		<div class="empty-page order-empty" style="display:none">
	            <i style="background-image: url(/res/images/common/icon_no_order.png);"></i>
	            <p>您当前没有订单</p>
	   </div>
   </div>
    <aside>
        <ul class="listBox" id="spotOrderList">
        </ul>
    </aside>
    <script>
        /*---此句代码解决页面滑动的问题---*/
        window.PointerEvent = undefined;
        /*------------------------------*/
    </script>
    <script type="text/javascript" src="/js/commonJs.js?v=20170704"></script>
    <script type="text/javascript" src="/js/commonFoot.js?v=20170704"></script>
    <script type="text/javascript" src="/js/commonjs/orderBar.js"></script>
    <!-- start Dplus --><script src="/js/udplus.js"></script><!-- end Dplus -->
    <script type="text/javascript">
    
        function orderDetial(orderNo,ticketDec){
            var urlStr = SERVER_URL_PREFIX+'/sameSale/toDeatilPage';
            var dataObj = {	
            };
            dataObj = genReqData(urlStr, dataObj);
            window.location.href="/sameSale/toDeatilPage?token="+dataObj.token+"&orderNo="+orderNo;
        }
            // 分页选项
            var _options = {
                number: 0,  // 页码
                flag: false // 事件锁
            };
                    
            $(function() {
                // backtoUrl('/index');
                
                //导航栏
                getBusinessTypes('isSpot');//引入js/commonjs/orderBar.js
                
                //初始化
                bindPageEvent();
                requestServer();
            });
                
             // 绑定分页事件
            function bindPageEvent() {
                $(document.body).rollPage('destroy');
                /* $('#datalist').hideLoading(); */
                $(document.body).rollPage('load', function() {
                    // 页面滚动到底部请求下一页
                    requestServer();
                });
            }
            
            // 模拟数据请求
            var requestServer = function() {
                // 事件锁, 防止频繁触发事件
                if(_options.flag) return;
                _options.flag = true;
                // 显示分页指示器
                /* $('#datalist').loading(); */
        
                  //api url
                var urlStr = SERVER_URL_PREFIX+"/spot/order/getGoodsOrderList";
                //current page param
                var dataObj = {
                    orderType : 11,
                    page : _options.number+1,
                    pageSize : 5,
                };
                //merge page param and common param,generate request param
                dataObj = genReqData(urlStr, dataObj);
                    
                $.post(urlStr, dataObj, function(result){
                    /* $('#datalist').hideLoading(); */
                    _options.flag = false;   // 数据渲染完成，事件解锁
                    if (result.code == 0) {
                        var strHtml ='';
                        var totalCount = result.data.totalCount;
                        var list = result.data.data;
                        var pageSize = result.data.pageSize;
                        var spotOrderListHtml = '';

                        if (list.length <= 0) {
                            $(".empty-page").css('display', 'block');
                            $(document.body).rollPage('destroy');   // 销毁事件
                            /* $('#datalist').hideLoading(); */
                        } else {
                            list.forEach(function (item,index) {
                                // 门票订单状态 0--待支付,4--已支付，6-已完成 7-已取消 8--已关闭
                                // 样式 toPay:待支付 pay：已支付
                                let createTime = formatTime(item.createTime);
                                let ticketDec = item.ticketDec + " - "+ item.ticketCount +"张";
                                if(item.subOrderStatus == 0){
                                    spotOrderListHtml +='<li class="orderList" onclick="orderDetial(\''+item.orderNo+'\''+ ',\'' + ticketDec + '\')"><div class="orderTime flex jcs"><div>下单时间：'+ createTime +'</div><div class="toPay">待支付</div></div><div class="orderDetail"><div class="orderData">'+ item.startDate +'</div><div>'+ item.productName +'</div><div class="flex jcs"><div>' +ticketDec+ '</div><div class="orderPrice"></div></div></div></li>';
                                }else if(item.subOrderStatus == 4){
                                    spotOrderListHtml +='<li class="orderList" onclick="orderDetial(\''+item.orderNo+'\''+ ',\'' + ticketDec + '\')"><div class="orderTime flex jcs"><div>下单时间：'+ createTime +'</div><div class="pay">已支付</div></div><div class="orderDetail"><div class="orderData">'+ item.startDate +'</div><div>'+ item.productName +'</div><div class="flex jcs"><div>' +ticketDec+ '</div><div class="orderPrice">' +item.payPrice+ '元</div></div></div></li>';
                                }else if(item.subOrderStatus == 6){
                                    spotOrderListHtml +='<li class="orderList" onclick="orderDetial(\''+item.orderNo+'\''+ ',\'' + ticketDec + '\')"><div class="orderTime flex jcs"><div>下单时间：'+ createTime +'</div><div class="pay">已完成</div></div><div class="orderDetail"><div class="orderData">'+ item.startDate +'</div><div>'+ item.productName +'</div><div class="flex jcs"><div>' +ticketDec+ '</div><div class="orderPrice">' +item.payPrice+ '元</div></div></div></li>';
                                }else if(item.subOrderStatus == 7){
                                    spotOrderListHtml +='<li class="orderList" onclick="orderDetial(\''+item.orderNo+'\''+ ',\'' + ticketDec + '\')"><div class="orderTime flex jcs"><div>下单时间：'+ createTime +'</div><div>已取消</div></div><div class="orderDetail"><div class="orderData">'+ item.startDate +'</div><div>'+ item.productName +'</div><div class="flex jcs"><div>' +ticketDec+ '</div><div class="orderPrice"></div></div></div></li>';
                                }else if(item.subOrderStatus == 8){
                                    spotOrderListHtml +='<li class="orderList" onclick="orderDetial(\''+item.orderNo+'\''+ ',\'' + ticketDec + '\')"><div class="orderTime flex jcs"><div>下单时间：'+ createTime +'</div><div>已关闭</div></div><div class="orderDetail"><div class="orderData">'+ item.startDate +'</div><div>'+ item.productName +'</div><div class="flex jcs"><div>' +ticketDec+ '</div><div class="orderPrice"></div></div></div></li>';
                                }
                            })
                            $("#spotOrderList").append(spotOrderListHtml);
                        }
                        _options.number++;
                        _options.flag = false;
                        //最后一页销毁加载器
                        var pageCount = 1;
                        if(totalCount%pageSize == 0){
                            pageCount = totalCount/pageSize
                        }else{
                            pageCount = totalCount/pageSize + 1;
                        }                
                        if(_options.number < pageCount){
                            if(list.length<5){
                                $(document.body).rollPage('destroy');   // 销毁事件
                            }
                        }else{
                            $(document.body).rollPage('destroy');   // 销毁事件
                        }
                        
                    }
                },'json');
                
            }
    </script>
    
</body>
</html>
